﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Com.Toook.ParseHtml;
using Com.Toook.ParseHtml.Entity;
using Com.Toook.RssNews;
using System.IO;
using System.Data.OleDb;
using Com.Toook.Common;
using Com.Toook.UpdateRssNews;

public partial class getNewsContent : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void ButtonGetContent_Click(object sender, EventArgs e)
    {
        string xmlFilePath = Server.MapPath("~\\App_Data\\RssNewsContent\\sohu.com.xml");
        //GetKindResultFromHtml html = new GetKindResultFromHtml(xmlFilePath, "xddy_xj");
        //html.GetKindPageResults();
        string siteId = TextBoxUrl.Text;
        CreateContentByXml createContent = new CreateContentByXml(xmlFilePath);
        DetailRoadMap roadMap = createContent.GetDetailRoadMap("sohu_common");
        GetContentResultFromHtml html = new GetContentResultFromHtml(roadMap);
        html.GetRssNewsContent(120);
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string xmlFilePath = Server.MapPath("~\\App_Data\\ListArticle\\sbkk8.cn.xml");
       
        string siteId = TextBoxSiteKindId.Text;
        GetKindResultFromHtml htmlKind = new GetKindResultFromHtml(xmlFilePath, siteId);
        htmlKind.GetKindPageResults();

        CreateContentByXml createContent = new CreateContentByXml(xmlFilePath);
        DetailRoadMap roadMap = createContent.GetDetailRoadMap(siteId);
        GetContentResultFromHtml html = new GetContentResultFromHtml(roadMap);
        html.GetContent();
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        //UpdateRssNews h = new UpdateRssNews();
        //h.UpdateAllSiteNews();
    }
    protected void ButtonUpdateOneMySql_Click(object sender, EventArgs e)
    {
        UpdateRssNewsMySql h = new UpdateRssNewsMySql();
        h.UpdateOneSite(int.Parse(TextBoxSiteId.Text));//RssSites表的id
        

    }
    protected void Button3_Click(object sender, EventArgs e)
    {        
        //string localPage = Server.MapPath("~/TestNSoupPage.html");
        //FileStream fs = File.OpenRead(localPage);
        //NSoup.Nodes.Document doc = NSoup.NSoupClient.Parse(fs, "UTF-8");
        //NSoup.Nodes.Element content = doc.GetElementById("artibody");
        //NSoup.Select.Elements conmments = content.GetElementsByTag("conmment");
       
        //string detail = content.Html().Replace("<!--.+-->", "");
    }
    protected void ButtonUpdateOneAccess_Click(object sender, EventArgs e)
    {
        UpdateRssNewsAccess h = new UpdateRssNewsAccess();
        h.UpdateOneSite(int.Parse(TextBoxSiteId.Text));//RssSites表的id
    }
    /// <summary>
    /// 先下载列表到*Temp,再下载内容
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void ButtonKindAndContent_Click(object sender, EventArgs e)
    {
        string xmlFilePath = Server.MapPath("~\\App_Data\\" + txtKCxml.Text.Trim() + ".xml");

        string siteId = txtKCsiteId.Text.Trim();
        GetKindResultFromHtml htmlKind = new GetKindResultFromHtml(xmlFilePath, siteId);
        htmlKind.GetKindPageResults();

        CreateContentByXml createContent = new CreateContentByXml(xmlFilePath);
        DetailRoadMap roadMap = createContent.GetDetailRoadMap(siteId);
        GetContentResultFromHtml html = new GetContentResultFromHtml(roadMap);
        html.GetContent();
        lblKC.Text = "完成：" + siteId;
    }
}
